package cn.whit.blog.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

public class JsonUtils {
	
	public static Map<String, String> getJsonMap(HttpServletRequest request)
			throws UnsupportedEncodingException, IOException {
		BufferedReader streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(), "UTF-8"));  
        StringBuilder responseStrBuilder = new StringBuilder();
        String inputStr;  
        while ((inputStr = streamReader.readLine()) != null)  
        	responseStrBuilder.append(inputStr);  
        
        Map<String ,String> map = (Map<String, String>) JSONObject.toBean(JSONObject.fromObject(responseStrBuilder.toString()),Map.class);
		return map;
	}
}
